package Top101K;

/**
 * @Author quan
 * @Description 冒泡排序
 * @Date 2023/10/20 10:41
 */
public class a05_bubbleSort {
    //冒泡排序
    public static void main(String[] args) {
        int[] arr = {1,3,5,2,4,6};
        for (int i = 0; i < arr.length; i++) {
            for (int j = 0; j < arr.length-1-i; j++) {
                if(arr[j] < arr[j+1]){
                    swap(arr,j,j+1);
                }
            }
        }
        for (int i = 0; i < arr.length; i++) {
            System.out.println(arr[i]);
        }
    }
    public static void swap(int[] arr,int i,int j){
        int temp = arr[i];
        arr[i] = arr[j];
        arr[j] = temp;
    }
}
